// Physical memory layout

// 0x00200000 -- bios loads kernel here and jumps here
// 0x10000000 --
// 0x1c000000 -- reset address
// 0x1fe00000 -- I/O interrupt base address
// 0x1fe001e0 -- uart16550 serial port
// 0x90000000 -- RAM used by user pages

#ifndef __phy_layout_h_
#define __phy_layout_h_

#include "arch/loongarch.h"

// the kernel expects there to be RAM
// for use by user pages from physical address 0x90000000 to PHYSTOP.
#define RAMBASE (0x90000000UL | DMWIN_MASK)
#define RAMSTOP (RAMBASE + 128 * 1024 * 1024)

// User memory layout.
// Address zero first:
//   text
//   original data and bss
//   fixed-size stack
//   expandable heap
//   ...
//   invalid guard page
//   KSRACK (used for kernel thread)
//   TRAPFRAME (p->trapframe, used by the uservec)
#define TRAPFRAME (MAXVA - PGSIZE)

// map kernel stacks beneath the trampframe,
// each surrounded by invalid guard pages.
#define KSTACK(p) (TRAPFRAME - ((p) + 1) * 2 * PGSIZE)

#endif
